home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / solaris2 / jdk / src / java / net / socketi0.jav < prev    next >
Encoding:
Text File  |  1995-10-30  |  3.6 KB  |  119 lines

  1. /*
  2.  * @(#)SocketImpl.java    1.12 95/10/18 Jonathan Payne
  3.  *
  4.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. package java.net;
  21.  
  22. import java.io.IOException;
  23. import java.io.InputStream;
  24. import java.io.OutputStream;
  25.  
  26. /**
  27.  * This is the Socket implementation class. It is an
  28.  * abstract class that must be subclassed to provide
  29.  * an actual implementation.
  30.  *
  31.  * @version     1.12, 10/18/95
  32.  * @author     Jonathan Payne
  33.  * @author     Arthur van Hoff
  34.  */
  35. public abstract class SocketImpl {
  36.  
  37.     /**
  38.      * The file descriptor.
  39.      */
  40.     protected int fd;
  41.  
  42.     /**
  43.      * The internet address where the socket will make connection.
  44.      */
  45.     protected InetAddress address;
  46.    
  47.     /**
  48.      * The port where the socket will make connection.
  49.      */
  50.     protected int port;
  51.     protected int localport;   
  52.  
  53.     /**
  54.      * Creates a socket with a boolean that specifies whether this
  55.      * is a stream socket or a datagram socket.
  56.      * @param stream a boolean indicating whether this is a stream
  57.      * or datagram socket
  58.      */
  59.     protected abstract void create(boolean stream) throws IOException;
  60.  
  61.     /**
  62.      * Connects the socket to the specified port on the specified host.
  63.      * @param host the specified host of the connection
  64.      * @param port the port where the connection is made
  65.      */
  66.     protected abstract void connect(String host, int port) throws IOException;
  67.  
  68.     /**
  69.      * Connects the socket to the specified address on the specified
  70.      * port.
  71.      * @param address the specified address of the connection
  72.      * @param port the specified port where connection is made
  73.      */
  74.     protected abstract void connect(InetAddress address, int port) throws IOException;
  75.  
  76.     /**
  77.      * Binds the socket to the specified port on the specified host.
  78.      * @param host the host
  79.      * @param port the port   
  80.      */
  81.     protected abstract void bind(InetAddress host, int port) throws IOException;
  82.  
  83.     /**
  84.      * Listens for connections over a specified amount of time.
  85.      * @param count the amount of time this socket will listen for 
  86.      * connections
  87.      */
  88.     protected abstract void listen(int count) throws IOException;
  89.  
  90.     /**
  91.      * Accepts a connection.
  92.      * @param s the accepted connection
  93.      */
  94.     protected abstract void accept(SocketImpl s) throws IOException;
  95.  
  96.     /**
  97.      * Gets an InputStream for this socket.
  98.      */
  99.     protected abstract InputStream getInputStream() throws IOException;
  100.  
  101.     /**
  102.      * Gets an OutputStream for this socket.
  103.      */
  104.     protected abstract OutputStream getOutputStream() throws IOException;
  105.  
  106.     /**
  107.      * Closes the socket.
  108.      */
  109.     protected abstract void close() throws IOException;
  110.  
  111.     /**
  112.      * Returns the address and port of this Socket as a String.
  113.      */
  114.     public String toString() {
  115.     return "Socket[fd=" + (fd-1) + ",addr=" + address +
  116.         ",port=" + port + ",localport=" + localport + "]";
  117.     }
  118. }
  119.